<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller {

	public $data;

	public function __construct()
	{
		parent::__construct();
	}

	public function index()
	{
		//check if logged in
		if(null == $this->session->userdata('userInfo')) //if not login
			redirect('login');

		if(null != $this->session->userdata('loginError'))
			$this->session->unset_userdata('loginError');
		
		$userdata = $this->session->userdata('userInfo');
		$data = array(
			'title' => 'Khai nghiệp | Bảng điều khiển',
			'name' => $userdata['name']
		);

		$this->load->view('tmpl/header', $data);
		$this->load->view('tmpl/left', $data);
		$this->load->view('home_view', $data);
		$this->load->view('tmpl/footer');
	}

	//logout
	public function logout() {
		//check if logged in
		if(null == $this->session->userdata('userInfo')) //if not login
			redirect('login');

		//destroy session
		$this->session->unset_userdata('userInfo');	
		redirect('login');
	}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */